/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package intraverbal;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.RollbackException;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author Anderson
 */
@Entity
@Table(name = "palavra", catalog = "intraverbal", schema = "public")
@NamedQueries({
    @NamedQuery(name = "Palavra.findAll", query = "SELECT p FROM Palavra p"),
    @NamedQuery(name = "Palavra.findByIdPalavra", query = "SELECT p FROM Palavra p WHERE p.idPalavra = :idPalavra"),
    @NamedQuery(name = "Palavra.findByidioma1", query = "SELECT p FROM Palavra p WHERE p.idioma1 = :idioma1"),
    @NamedQuery(name = "Palavra.findByidioma2", query = "SELECT p FROM Palavra p WHERE p.idioma2 = :idioma2"),
    @NamedQuery(name = "Palavra.findByfase", query = "SELECT p FROM Palavra p WHERE p.fase = :fase")})

public class Palavra implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id_palavra")
    private Integer idPalavra;
    @Column(name = "Idioma1")
    private String idioma1;
    @Column(name = "Idioma2")
    private String idioma2;
    @Column (name = "Fase")
    private int fase;

    public Palavra() {
    }

    public Palavra(Integer idPalavra) {
        this.idPalavra = idPalavra;
    }

    public Integer getIdPalavra() {
        return idPalavra;
    }

    public void setIdPalavra(Integer idPalavra) {
        Integer oldIdPalavra = this.idPalavra;
        this.idPalavra = idPalavra;
        changeSupport.firePropertyChange("idPalavra", oldIdPalavra, idPalavra);
    }

    public String getIdioma1() {
        return idioma1;
    }

    public void setIdioma1(String idioma1) {
        String oldIdioma1 = this.idioma1;
        this.idioma1 = idioma1;
        changeSupport.firePropertyChange("idioma1", oldIdioma1, idioma1);
    }

    public String getIdioma2() {
        return idioma2;
    }

    public void setIdioma2(String idioma2) {
        String oldIdioma2 = this.idioma2;
        this.idioma2 = idioma2;
        changeSupport.firePropertyChange("idioma2", oldIdioma2, idioma2);
    }
    
    public int getFase(){
        return fase-1;
    }
    
    public void setFase(int fase) {
        try{
        int oldFase = this.fase;
        this.fase = fase+1;
        changeSupport.firePropertyChange("fase", oldFase, fase+1);
        }catch(RollbackException rex){
           
        };
     }    

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idPalavra != null ? idPalavra.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Palavra)) {
            return false;
        }
        Palavra other = (Palavra) object;
        if ((this.idPalavra == null && other.idPalavra != null) || (this.idPalavra != null && !this.idPalavra.equals(other.idPalavra))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "intraverbal.Palavra[ idPalavra=" + idPalavra + " ]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
